package com.atguigu.gmall.file;

import org.csource.fastdfs.*;
import org.springframework.util.ClassUtils;

/**
 * @Author: 李旭
 * @Time: 15:10
 * @Description:
 */
public class FileUploadDemo {

    public static void main(String[] args) throws Exception{

        //D:\IdeaProjects\gmall-201116\gmall-parent\service\service-product\src\main\resources\fdfs_client.conf
        String path = ClassUtils.getDefaultClassLoader().
                getResource("fdfs_client.conf").getPath();
        //0:配置跟踪器的ip:port
        ClientGlobal.init(path);
        //1:创建TrackerClient 客户端   192.168.200.136:22122
        TrackerClient trackerClient = new TrackerClient();
        //2:连接TrackerServer端
        TrackerServer trackerServer = trackerClient.getConnection();
        //3:创建Storage的客户端
        StorageServer storageServer = null;
        StorageClient1 storageClient1 = new StorageClient1(trackerServer,storageServer);
        //4:上传文件   meta : 元数据信息  作者  什么时候 多大 有意思吗？
        String fileId = storageClient1.upload_file1(
                "D:\\尚品汇商城\\资料\\图片\\Apple11\\5f7eafcd01dd2304.jpg"
                , "jpg", null);
        System.out.println(fileId);
        //    http://192.168.200.136:8080/group1/M00/00/00/wKjIgWCXj76AAKhQAAT8_AoEzOU949.jpg
    }


}
